package com.chatcompetition.controller;


import com.chatcompetition.domain.entity.CompetitionActivity;
import com.chatcompetition.service.CompetitionActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/competitionActivity")
public class CompetitionActivityController {

    @Autowired
    private CompetitionActivityService competitionActivityService;
    //打印全部的信息（超级管理员的权限）



    // 添加人老师查询自己添加的所有竞赛
    @GetMapping("/competitionsAddTeachers")
    public List<CompetitionActivity> listAllCompetitionsAddTeachers() {
        return competitionActivityService.listAllCompetitionsAddTeachers();
    }
//获取所有的信息
    @GetMapping("/competitions")
    public List<CompetitionActivity> getAllCompetitions() {
        return competitionActivityService.getAllCompetitions();
    }


    // 添加人老师查询自己添加的所有活动
    @GetMapping("/activitiesAddTeachers")
    public List<CompetitionActivity> listAllActivitiesAddTeachers() {
        return competitionActivityService.listAllActivitiesAddTeachers();
    }

    @GetMapping("/{id}")
    public CompetitionActivity getById(@PathVariable Long id) {
        return competitionActivityService.getById(id);
    }

    @PostMapping("/save")
    public boolean save(@RequestBody CompetitionActivity activity) {
        return competitionActivityService.save(activity);
    }

    @PutMapping("/update")
    public boolean update(@RequestBody CompetitionActivity activity) {
        return competitionActivityService.update(activity);
    }

    @DeleteMapping("/{id}")
    public boolean delete(@PathVariable Long id) {
        return competitionActivityService.delete(id);
    }
    @GetMapping("/sub-categories")
    public List<String> getSubCategoriesByCategory(@RequestParam String category) {
        return competitionActivityService.getSubCategoriesByCategory(category);
    }

    /**
     * 根据类别和种类查询竞赛活动
     */
    @GetMapping("/competitions-filter")
    public List<CompetitionActivity> getCompetitions(
            @RequestParam(required = false) String category,
            @RequestParam(required = false) String sub_category) {
        return competitionActivityService.getCompetitionsByFilters(category, sub_category);
    }
}